import { observable, computed, action, makeObservable } from 'mobx';

class userStoreClass {
  constructor() {
    makeObservable(this)
  }

  @observable user = {
    token: window.localStorage.getItem('token') || ''
  };

  @computed get userName() {
    return this.user.name;
  }

  @action setToken(token) {
    this.user.token = token
    window.localStorage.setItem('token',this.user.token)
  }

}

const userStore = new userStoreClass();

export default userStore;